package com.lj.demo.springbootshirojwt.service.impl;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lj.demo.springbootshirojwt.service.IForumService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Title: 论坛service实现类
 * Description:
 * Date: 2019年06月27日 9:09
 *
 * @author lvjie@hiynn.com
 * @version 1.0
 * Significant Modify：
 * Date                  Author                 Content
 * =================================================================
 * 2019年06月27日         lvjie@hiynn.com         创建文件,实现基本功能
 * =================================================================
 */
@Service
public class ForumServiceImpl implements IForumService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ForumServiceImpl.class);

    /**
     * 获取主题列表  登录可访问
     * @return
     */
    @Override
    @RequiresAuthentication
    public List<Map<String, Object>> listThemes() {
        LOGGER.info("模拟数据库查询");
        List<Map<String,Object>> themes = Lists.newArrayList();
        Map<String,Object> theme = Maps.newHashMapWithExpectedSize(2);
        theme.put("name","springboot+shiro+jwt整合实现RestFull风格服务器无状态鉴权");
        theme.put("id","123456789");
        themes.add(theme);
        return themes;
    }

    /**
     * 修改主题  需要能修改主题的权限
     */
    @Override
    @RequiresPermissions("FORUM_UPDATE")
    public void updateTheme() {
        LOGGER.info("模拟修改主题,success");
    }
}
